package com.ruoyi.health.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.health.mapper.BmServiceMapper;
import com.ruoyi.health.domain.BmService;
import com.ruoyi.health.service.IBmServiceService;

/**
 * 便民服务Service业务层处理
 *
 * @author dalian
 * @date 2023-08-06
 */
@Service
public class BmServiceServiceImpl implements IBmServiceService {
    @Autowired
    private BmServiceMapper bmServiceMapper;

    /**
     * 查询便民服务
     *
     * @param id 便民服务主键
     * @return 便民服务
     */
    @Override
    public BmService selectBmServiceById(Long id) {
        return bmServiceMapper.selectBmServiceById(id);
    }

    /**
     * 查询便民服务列表
     *
     * @return 便民服务
     */
    @Override
    public List<BmService> selectBmServiceList(String itemName,
            Long staffNumMin, Long staffNumMax,
            Long sinceMin, Long sinceMax,
            Long serviceItemId, Long typeId,
            Long region1Id,
            Long region2Id) {
        //先查询 某个区域中提供的所有服务
        List<Long> bmServIds = bmServiceMapper.selectServiceIdByServiceRegion(region1Id, region2Id, null);

        return bmServiceMapper.selectBmServiceList(itemName, staffNumMin, staffNumMax,
                sinceMin, sinceMax, serviceItemId, typeId, bmServIds);
    }

    /**
     * 新增便民服务
     *
     * @param bmService 便民服务
     * @return 结果
     */
    @Override
    public int insertBmService(BmService bmService) {
        bmService.setCreateTime(DateUtils.getNowDate());
        return bmServiceMapper.insertBmService(bmService);
    }

    /**
     * 修改便民服务
     *
     * @param bmService 便民服务
     * @return 结果
     */
    @Override
    public int updateBmService(BmService bmService) {
        return bmServiceMapper.updateBmService(bmService);
    }

    /**
     * 批量删除便民服务
     *
     * @param ids 需要删除的便民服务主键
     * @return 结果
     */
    @Override
    public int deleteBmServiceByIds(Long[] ids) {
        return bmServiceMapper.deleteBmServiceByIds(ids);
    }

    /**
     * 删除便民服务信息
     *
     * @param id 便民服务主键
     * @return 结果
     */
    @Override
    public int deleteBmServiceById(Long id) {
        return bmServiceMapper.deleteBmServiceById(id);
    }
}
